package com.zzty.zzlp.dao;

import com.zzty.zzlp.entity.Article;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface ArticleMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(Article record);

    int insertSelective(Article record);

    Article selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(Article record);

    int updateByPrimaryKeyWithBLOBs(Article record);

    int updateByPrimaryKey(Article record);

    @Insert("insert into article (title,author,content,summary,time,userId,imgUrl,type,comment) values (#{title},#{author},#{content},#{summary},#{time},#{userId},#{imgUrl},1,#{comment})")
    int insert1(Article record);

    @Select("select * from article where type=1")
    List<Article> selectAllArticle();

    @Select("select * from article where userId = #{userId} and type=1")
    List<Article> selectSelf(@Param("userId") Integer userId);

    @Select("select * from article where userId = #{userId} and type=0 order by id desc limit 1")
    Article Asel(@Param("userId") Integer userId);

    @Insert("insert into article (title,author,content,summary,time,userId,imgUrl,type,comment) values (#{title},#{author},#{content},#{summary},#{time},#{userId},#{imgUrl},0,#{comment})")
    int insertA1(Article record);

    @Delete("delete from article where userId=#{userId} and type=0")
    int del(@Param("userId") Integer userId);

    @Delete("delete from article where type=0 and id=#{id}")
    int del2(@Param("id") Integer id);
}